package star.cloud.asme.system.dictionary;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import star.cloud.asme.base.dto.Result;
import star.cloud.asme.base.mybatis.IBaseController;

import java.util.List;

@RestController
@RequestMapping("/system/dictionary")
@RequiredArgsConstructor
@Slf4j
public class DictionaryController implements IBaseController<Dictionary> {

    private final DictionaryService dictionaryService;

    @Override
    public Result<Dictionary> getOneByCondition(String columnName, Object columnValue) {
        return dictionaryService.getOneByCondition(columnName, columnValue);
    }

    @Override
    public Result<List<Dictionary>> getListByConditions(Dictionary conditions) {
        return dictionaryService.getListByConditions(conditions);
    }

    @Override
    public Result<IPage<Dictionary>> getListByConditionsWithPage(Dictionary conditions) {
        return dictionaryService.getListByConditionsWithPage(conditions);
    }

    @Override
    public Result<Dictionary> insertOne(Dictionary entity) {
        return dictionaryService.insertOne(entity);
    }

    @Override
    public Result<Dictionary> updateOne(Dictionary entity) {
        return dictionaryService.updateOne(entity);
    }

    @Override
    public Result<?> physicalDeleteById(Long id) {
        return dictionaryService.physicalDeleteById(id);
    }

    @Override
    public Result<?> logicalDeleteById(Long id) {
        return dictionaryService.logicalDeleteById(id);
    }


    @Override
    public Result<?> activeById(Long id) {
        return dictionaryService.activeById(id);
    }

    @PutMapping("/{id}/direction/{direction}")
    public Result<Dictionary> changeSequence(@PathVariable Long id, @PathVariable String direction) {
        return dictionaryService.changeSequence(id, direction);
    }

    @GetMapping("/maxSequence/{typeText}")
    public Result<Integer> getMaxSequence(@PathVariable String typeText) {
        return dictionaryService.getMaxSequence(typeText);
    }
}